<template>
	<view>
		<u-gap height="40" bg-color="#ffffff"></u-gap>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="pic" size="140"></u-avatar>
			</view>
			<view class="u-flex-1" v-if="name != ''">
				<view class="u-font-18 u-p-b-20">{{name}}</view>
				<view class="u-font-14 u-tips-color">ID：{{id}}</view>
			</view>
			<view class="u-flex-1" v-if="name == ''">
				<view class="u-font-18 u-p-b-20">还未登陆，请先登录</view>
				<view class="u-font-14 u-tips-color"><button style="width: 60%;float: left;"
						@click="login()">登陆</button> </view>
			</view>
		</view>
		<view v-if="name != ''">
			<view class="u-m-t-20">
				<u-cell-group>
					<u-cell-item @click="openPage('/pages/center/updateinfo')" icon="account" title="修改个人信息">
					</u-cell-item>
					<u-cell-item @click="openPage('/pages/callpolice/history')" icon="warning" title="我的报警">
					</u-cell-item>
					<u-cell-item @click="openPage('/pages/center/prize')" icon="gift-fill" title="中奖历史"></u-cell-item>
				</u-cell-group>
			</view>
			<u-gap height="500"></u-gap>
			<view class="u-m-t-20" style="width: 100%;height: 100rpx;position: fixed;bottom: 0rpx;" >
				<u-cell-group >
					<u-button type="primary" class="btn" @click="Logout('pages/index/login')"  >切换账号</u-button>
				</u-cell-group>
			</view>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				pic: '',
				show: true,
				name: '',
				id: '',
				reputation: '',
				form: {
					bookNumber: ''
				}
			}
		},
		onReady() {

		},
		onLoad() {
			this.name = getApp().globalData.studentName
			this.id = getApp().globalData.studentId
			console.log(this.name);
			console.log(this.id);
		},
		onShow() {

		},
		created() {

		},
		computed: {
			current() {
				return this.show ? 0 : 1;
			}
		},
		methods: {
			openPage(path) {
				uni.navigateTo({
					url: path
				})
			},
			Logout(path) {
				getApp().globalData.studentName = "";
				getApp().globalData.studentId = "";
				getApp().globalData.studentCollege = "";
				this.$u.route({
					url: path,
					type: 'redirectTo'
				})
			},
			login() {
				this.$u.route({
					url: 'pages/index/login',
					type: 'redirectTo'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #ededed;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}
	.btn{
		background-color: #FFFFFF;
	}
</style>
